unity find all scriptable objects of a type

209

unity find all scriptable objects of a type -

public class CharacterList
    {
        List<Character> characterList = new List<Character>();

        void PopulateList()
        {
            string[] assetNames = AssetDatabase.FindAssets("Your_Filter", new[] { "Assets/YourFolder" });
            characterList.Clear();
            foreach (string SOName in assetNames)
            {
                var SOpath    = AssetDatabase.GUIDToAssetPath(SOName);
                var character = AssetDatabase.LoadAssetAtPath<Character>(SOpath);
                characterList.Add(character);
            }
        }
    }

Comments

Submit
0 Comments